import request from '@/http/request'
import $infoBox from '@/utils/infoBox'

/*
 *  全系列restful api格式, 定义通用req对象
 *
 *  @author terrfly
 *  @site https://www.jeepay.vip
 *  @date 2021/5/8 07:18
 */
export const req = {

  // 通用列表查询接口
  list: (url, params) => {
    return request.request({ url: url, method: 'GET', params: params }, true, true, false)
  },

  // 通用新增接口
  add: (url, data) => {
    return request.request({ url: url, method: 'POST', data: data }, true, true, false)
  },

  // 通用查询单条数据接口
  getById: (url, bizId, params = {} ) => {
    return request.request({ url: url + '/' + bizId, method: 'GET', params: params }, true, true, false)
  },

  // 通用修改接口
  updateById: (url, bizId, data) => {
    return request.request({ url: url + '/' + bizId, method: 'PUT', data: data }, true, true, false)
  },

  // 通用删除接口
  delById: (url, bizId) => {
    return request.request({ url: url + '/' + bizId, method: 'DELETE' }, true, true, false)
  },

  // 通用 新增 or 更新
  addOrUpdate: (bizId, url, data, showMessage = true) => {

    //包含bizId 请求的是修改接口
    if(bizId){
      return req.updateById(url, bizId, data).then(res => {
        if(showMessage) $infoBox.message.success('更新成功')
        return Promise.resolve(res)
      })

    }else{

      return req.add(url, data).then(res => {
        if(showMessage) $infoBox.message.success('新增成功')
        return Promise.resolve(res)
      })

    }

  }

}

// 全系列restful api格式 (全局loading方式)
export const reqLoad = {

  // 通用列表查询接口
  list: (url, params) => {
    return request.request({ url: url, method: 'GET', params: params }, true, true, true)
  },

  // 通用新增接口
  add: (url, data) => {
    return request.request({ url: url, method: 'POST', data: data }, true, true, true)
  },

  // 通用查询单条数据接口
  getById: (url, bizId, params = {} ) => {
    return request.request({ url: url + '/' + bizId, method: 'GET', params: params }, true, true, true)
  },

  // 通用修改接口
  updateById: (url, bizId, data) => {
    return request.request({ url: url + '/' + bizId, method: 'PUT', data: data }, true, true, true)
  },

  // 通用删除接口
  delById: (url, bizId) => {
    return request.request({ url: url + '/' + bizId, method: 'DELETE' }, true, true, true)
  }
}

/** 角色管理页面 **/
export const API_URL_ENT_LIST = '/api/sysEnts'
export const API_URL_ROLE_LIST = '/api/sysRoles'
export const API_URL_ROLE_ENT_RELA_LIST = '/api/sysRoleEntRelas'
export const API_URL_SYS_USER_LIST = '/api/sysUsers'
export const API_URL_SYS_USER_TEAM_LIST = '/api/userTeams'
export const API_URL_SYS_USER_TEAM_USER_LIST = 'api/userTeams/userList'
export const API_URL_USER_ROLE_RELA_LIST = '/api/sysUserRoleRelas'

/** 服务商、商户管理**/
export const API_URL_ISV_LIST = '/api/isvInfo'
export const API_URL_MCH_LIST = '/api/mchInfo'

/** 代理商 **/
export const API_URL_AGENT_LIST = '/api/agents'
/** 代理商配置 **/
export const API_URL_AGENT_CONFIG = '/api/agentConfig'

/** 商户App管理 **/
export const API_URL_MCH_APP = '/api/mchApps'
/** 支付订单管理 **/
export const API_URL_PAY_ORDER_LIST = '/api/payOrder'
/** 退款订单管理**/
export const API_URL_REFUND_ORDER_LIST = '/api/refundOrder'
/** 商户通知管理 **/
export const API_URL_MCH_NOTIFY_LIST = '/api/mchNotify'
/** 系统日志 **/
export const API_URL_SYS_LOG = '/api/sysLog'
/** 设备厂商配置 **/
export const API_URL_DEVICE_PROVIDER = '/api/device/provider'
/** 钱包流水列表 **/
export const API_URL_WALLET_HISTORY_LIST = '/api/accountHistory'
/** 门店设备配置 **/
export const API_URL_STORE_DEVICE = '/api/store/device'
/** 系统配置 **/
export const API_URL_SYS_CONFIG = '/api/sysConfigs'
/** 法定节假日 **/
export const API_URL_SYS_LEGAL_DAY = '/api/sysLegelDay'
/** 首页统计 **/
export const API_URL_MAIN_STATISTIC = '/api/mainChart'

/** 支付接口定义页面 **/
export const API_URL_IFDEFINES_LIST = '/api/payIfDefines'
export const API_URL_PAYWAYS_LIST = '/api/payWays'
/** 商户支付通道配置 **/
export const API_URL_MCH_PAYPASSAGE_LIST = '/api/mch/payPassages'
/** 转账订单管理 **/
export const API_URL_TRANSFER_ORDER_LIST = '/api/transferOrders'

/** 进件管理 **/
export const API_URL_MCH_APPLYMENT_LIST = '/api/mchApplyments'

/** 版本管理 **/
export const API_URL_CLIENT_VERSION_LIST = '/api/clientVersion'

/** 商户门店管理 **/
export const API_URL_MCH_STORE_LIST = '/api/mchStore'
/** 商户三方账户管理 **/
export const ENT_MCH_CHANNEL_ACCOUNT = '/api/channel/cashouts'

/** 分账组管理**/
export const API_URL_DIVISION_RECEIVER_GROUP = '/api/divisionReceiverGroups'

/** 分账账号管理 **/
export const API_URL_DIVISION_RECEIVER = '/api/divisionReceivers'

/** 三方账号信息 **/
export const API_URL_CHANNEL_ACCOUNT_INFO = '/api/channelAccountInfo'

/** 分账记录管理 **/
export const API_URL_PAY_ORDER_DIVISION_RECORD_LIST = '/api/division/records'

/** 分账回退管理 **/
export const API_URL_PAY_ORDER_DIVISION_REFUND_RECORD_LIST = '/api/division/refunds/records'

/** 账单批次管理 **/
export const API_URL_CHECK_BATCH_LIST = '/api/check/batch'

/** 渠道账单管理 **/
export const API_URL_CHANNEL_BILL_LIST = '/api/channel/bill'

/** 账单差异管理 **/
export const API_URL_CHECK_DIFF_LIST = '/api/check/diff'

/** 商户静态码管理 **/
export const API_URL_MCH_QR_CODE_LIST = '/api/mchQrCodes'

export const API_URL_UPLOAD_SINGLE_FILE_URL = process.env.VITE_API_BASE_URL + '/api/ossFiles/singleFile'

export const API_URL_QRC_SHELL_LIST = '/api/mchQrcShells'

export const API_URL_ISV_RATE_CONFIG = '/api/isvRateConfig'

export const API_URL_CASHOUT_RECORD = '/api/cashouts'


/** 商户配置 **/
export const API_URL_MCH_CONFIG = '/api/mchConfig'

export const API_URL_MCH_TERMINAL = '/api/mchTerminals'

/** 统计接口 **/
export const API_URL_STATISTIC = '/api/statistic'
/** 统计任务记录接口 **/
export const API_URL_STATS_RECORD = '/api/stats/record'
/** 公告*/
export const API_URL_NOTICELIST = '/api/sysArticles'
/** 广告 **/
export const API_URL_ADVERT = '/api/advert'

/** 支付宝服务商代运营授权接口 */
export const API_ALIPAY_SP_OPERATION = '/api/alipaySpOperation'

/** 支付宝  蚂蚁店铺接口 */
export const API_ALIPAY_SHOP = '/api/alipayShop'

/** 支付宝  如意设备接口 */
export const API_ALIPAY_IOT = '/api/alipayIot'

/** 会员管理 */
export const API_URL_MEMBER_LIST = '/api/member'

/** 会员账户流水 */
export const API_URL_MEMBER_ACCOUNT_HISTORY_LIST = API_URL_MEMBER_LIST + '/accountHistory'

/** 会员充值记录 */
export const API_URL_MEMBER_RECHARGE_RECORD_LIST = API_URL_MEMBER_LIST + '/rechargeRecord'

/** 会员充值规则 */
export const API_URL_MEMBER_RECHARGE_RULE_LIST = API_URL_MEMBER_LIST + '/rechargeRule'

/** 设备厂商参数接口 */
export const API_URL_PROVIDER_DEVICE = '/api/provider/device'

/** 直付通结算记录列表 */
export const API_URL_ZFT_SETT_RECORD = '/api/zftSettRecords'

/** 活动管理 （渠道侧活动报名） */
export const API_URL_CHANNEL_ACTIVITY = '/api/channel/activities'

/** 上传图片/文件地址 **/
export const upload = {
  avatar: request.baseUrl + '/api/ossFiles/avatar',
  ifBG: request.baseUrl + '/api/ossFiles/ifBG',
  cert: request.baseUrl + '/api/ossFiles/cert',
  wxFile: request.baseUrl + '/api/ossFiles/wxFile',
  applyment: request.baseUrl + '/api/ossFiles/applyment',
  wx3rdCheckFile: request.baseUrl + '/api/ossFiles/wx3rdCheckFile' // 解析微信三方校验文件
}
/** 导出文件地址 **/
export const exportExcelUrl = {
  payOrder: '/api/payOrder/exportExcel',
  refundOrder: '/api/refundOrder/exportExcel',
  transferOrder: '/api/transferOrders/exportExcel',
  qrCodes: '/api/mchQrCodes/exportExcel',
  statistic: '/api/statistic/export',
  memberInfo: '/api/member/exportExcel',
  agentCashouts: '/api/cashouts/exportExcel',
}

const api = {
  user: '/user',
  role_list: '/role',
  service: '/service',
  permission: '/permission',
  permissionNoPager: '/permission/no-pager',
  orgTree: '/org/tree'
}

export default api

/** 获取权限树状结构图**/
export function $getEntTree (sysType) {
  return request.request({ url: '/api/sysEnts/showTree?sysType=' + sysType, method: 'GET' })
}

/** 退款接口*/
export function $payOrderRefund (payOrderId, refundAmount, refundReason) {
  return request.request({
    url: '/api/payOrder/refunds/' + payOrderId,
    method: 'POST',
    data: { refundAmount, refundReason }
  })
}

/** 更新用户角色信息 */
export function $uSysUserRoleRela (sysUserId, roleIdList) {
  return request.request({
    url: 'api/sysUserRoleRelas/relas/' + sysUserId,
    method: 'POST',
    data: { roleIdListStr: JSON.stringify(roleIdList) }
  })
}

export function $getRoleList (parameter) {
  return request({
    url: '/api/sysRoles',
    method: 'get',
    params: parameter
  })
}

export function $getServiceList (parameter) {
  return request({
    url: api.service,
    method: 'get',
    params: parameter
  })
}

export function $getPermissions (parameter) {
  return request({
    url: api.permissionNoPager,
    method: 'get',
    params: parameter
  })
}

export function $getTeamUserList (recordId, parameter) {
  return request.request({
    url: API_URL_SYS_USER_TEAM_USER_LIST + '/' + recordId,
    method: 'GET',
    params: parameter
  })
}

export function $getOrgTree (parameter) {
  return request({
    url: api.orgTree,
    method: 'get',
    params: parameter
  })
}

// id == 0 add     post
// id != 0 update  put
export function $saveService (parameter) {
  return request({
    url: api.service,
    method: parameter.id === 0 ? 'post' : 'put',
    data: parameter
  })
}

export function $saveSub (sub) {
  return request({
    url: '/sub',
    method: sub.id === 0 ? 'post' : 'put',
    data: sub
  })
}

export function $getPayTrendCount (date) {
  return request.request({
    url: API_URL_MAIN_STATISTIC + '/payTrendCount',
    method: 'GET',
    params: {recentDay: date }
  })
}

export function $getNumCount (data) {
  return request.request({
    url: API_URL_MAIN_STATISTIC + '/payDayCount',
    method: 'GET',
    params: data
  })
}

export function $getIsvAndMchCount () {
  return request.request({
    url: API_URL_MAIN_STATISTIC + '/isvAndMchCount',
    method: 'GET'
  })
}

export function $getPayCount (parameter) {
  return request.request({
    url: API_URL_MAIN_STATISTIC + '/payCount',
    method: 'GET',
    params: {queryDateRange: parameter }
  })
}

export function $getPayType (parameter) {
  return request.request({
    url: API_URL_MAIN_STATISTIC + '/payTypeCount',
    method: 'GET',
    params: {queryDateRange: parameter }
  })
}

export function $getMainUserInfo (parameter) {
  return request.request({
    url: API_URL_MAIN_STATISTIC + '/' + parameter,
    method: 'GET'
  })
}

export function $updateUserPass (parameter) {
  return request.request({
    url: '/api/current/modifyPwd',
    method: 'put',
    data: parameter
  })
}

export function $updateUserInfo (parameter) {
  return request.request({
    url: '/api/current/user',
    method: 'put',
    data: parameter
  })
}

export function $getUserInfo () {
  return request.request({
    url: '/api/current/user',
    method: 'get'
  })
}

/** MFA认证信息 **/
export function $getMFAInfo () {
  return request.request({
    url: '/api/current/mfaInfo',
    method: 'get'
  })
}

/** MFA认证绑定 **/
export function $mfaBind (parameter) {
  return request.request({
    url: '/api/current/mfaBind',
    method: 'put',
    data: parameter
  })
}

/** MFA认证解绑 **/
export function $mfaRelieve (parameter) {
  return request.request({
    url: '/api/current/mfaRelieve',
    method: 'put',
    data: parameter
  })
}

/** 导出功能 **/
export function $exportExcel (url, params) {
  return request.exportExcel(url, params)
}

export function $getConfigs (parameter) {
  return request.request({
    url: API_URL_SYS_CONFIG + '/' + parameter,
    method: 'GET'
  })
}

export function $getEntBySysType (entId, sysType) {
  return request.request({
    url: '/api/sysEnts/bySysType',
    method: 'GET',
    params: { entId: entId, sysType: sysType }
  })
}

export function $mchNotifyResend (notifyId) {
  return request.request({
    url: '/api/mchNotify/resend/' + notifyId,
    method: 'POST'
  })
}

/** 查询支付宝授权地址URL **/
export function $queryAlipayIsvsubMchAuthUrl (mchAppId) {
  return request.request({
    url: '/api/mch/payConfigs/alipayIsvsubMchAuthUrls/' + mchAppId,
    method: 'GET'
  })
}

/** 建行通过激活码查询密钥接口 **/
export function $queryKeyByAuthCode (mchtNo,termNo,authCode) {
  return request.request({
    url: '/api/mch/payConfigs/queryKeyByAuthCode/' + mchtNo +'/'+termNo +'/'+authCode,
    method: 'GET'
  })
}

/** 建行更新密钥接口 **/
export function $updateKey (mchtNo,termNo,oldKey) {
  return request.request({
    url: '/api/mch/payConfigs/updateKey/' + mchtNo +'/'+termNo +'/'+oldKey,
    method: 'GET'
  })
}

/** 查询当前应用支持的支付接口**/
export function $getIfCodeByAppId(appId) {
  return request.request({
    url: '/api/mch/payConfigs/ifCodes/' + appId,
    method: 'GET'
  }, true, true, true)
}

/** 获取到webSocket的前缀 （ws://localhost）**/
export function getWebSocketPrefix() {
  // 获取网站域名 +  端口
  let domain = document.location.protocol + '//' + document.location.host

  // 判断api_base_url 是否设置
  if (process.env.VUE_APP_API_BASE_URL && process.env.VUE_APP_API_BASE_URL !== '/') {
    domain = process.env.VUE_APP_API_BASE_URL
  }

  if (domain.startsWith('https:')) {
    return 'wss://' + domain.replace('https://', '')
  } else {
    return 'ws://' + domain.replace('http://', '')
  }
}

/** 获取渠道用户ID二维码地址 **/
export function $getChannelUserQrImgUrl(ifCode, appId, extParam) {
  return request.request({
    url: '/api/mchChannel/channelUserId',
    method: 'GET',
    params: { ifCode, appId, extParam }
  })
}

/* 查询进件接口的最新状态*/
export function $getMchApplymentChannelState (applyId) {
  return request.request({
    url: '/api/mchApplyments/channelState/' + applyId,
    method: 'get'
  })
}


/* 查询合同信息 */
export function $getMchApplymentChannelSignInfo (applyId) {
  return request.request({
    url: '/api/mchApplyments/channelSignInfo/' + applyId,
    method: 'get'
  })
}

/* 合同信息(重签等) */
export function $getMchApplyReSign (applyId, extSignInfo) {
  return request.request({
    url: '/api/mchApplyments/channelSignInfo/' + applyId,
    method: 'get',
    params: { extSignInfo }
  })
}

/* 开户意愿查询*/
export function $getMchApplymentWxOpenInfo (applyId) {
  return request.request({
    url: '/api/mchApplyments/channelWxOpenInfo/' + applyId,
    method: 'get'
  })
}

/* 开户意愿查询*/
export function $getMchApplymentAlipayOpenInfo (applyId) {
  return request.request({
    url: '/api/mchApplyments/channelAlipayOpenInfo/' + applyId,
    method: 'get'
  })
}

/* 获取合并的进件信息（智能读取）*/
export function $getMergeApplyDetailInfos (mchNo, fixApplyId, currentPageIfCode) {
  return request.request({
    url: '/api/mchApplyments/mergeApplyDetailInfos/' + mchNo,
    method: 'get',
    params: { fixApplyId, currentPageIfCode }
  })
}


/* 获取请求参数 */
export function $getUploadFormParams (file, bizType) {
  return request.request({
    url: '/api/ossFiles/form',
    method: 'post',
    data: { bizType: bizType, sourceFileName: file.name, sourceFileSize: file.size }
  })
}

export function $getPasswordRules () {
  return request.request({
    url: '/api/anon/cipher/pwdRulesRegexp',
    method: 'get'
  })
}


/* 获取请求参数 */
export function $applymentAppConfig (applyId, mchAppId) {
  return request.request({
    url: '/api/mchApplyments/appConfig/' + applyId + '/' + mchAppId,
    method: 'post',
  })
}


/* 查询接口配置参数 */
export function $queryInterfaceConfig (applyId, applyIdConvertMchAppId, convertMchAppIfCode) {
  return request.request({
    url: '/api/mchApplyments/interfaceConfig/' + applyId,
    method: 'get',
    params: { applyIdConvertMchAppId, convertMchAppIfCode } // applyId 转换为 商户应用ID
  })
}

/* 配置 */
export function $configInterfaceConfig (applyId, mchAppId, configType, configVal, appConfigModeAndIfCode) {
  return request.request({
    url: '/api/mchApplyments/interfaceConfig/' + applyId + '/' + mchAppId,
    method: 'post',
    data: { configType, configVal, appConfigModeAndIfCode }
  })
}

/* 门店入驻申请 */
export function $applymentStore (storeId, state, applyId, params) {
  return request.request({
    url: '/api/mchApplyments/storeApplyment/' + storeId + '/' + state + '/' + applyId,
    method: 'post',
    data: { applyId, state, storeId, params }
  })
}

/* 配置 */
export function $qrcShellView (styleCode, configModel) {
  return request.request({
    url: '/api/mchQrcShells/view',
    method: 'post',
    data: {
      configModelStr: JSON.stringify(configModel),
      styleCode: styleCode
    }
  })
}


/* 二维码下载*/
export function $qrcShellViewByQrc (qrcId) {
  return request.request({
    url: '/api/mchQrcShells/viewByQrc/' + qrcId,
    method: 'get',
  })
}

/* orc识别 */
export function $orcScan (imgUrl, type) {
  return request.request({
    url: '/api/imgInfo/detail/',
    method: 'post',
    data: {imgUrl, type}
  })
}

/* 支付订单数据统计 */
export function $payOrderCount (parameter) {
  return request.request({
    url: '/api/payOrder/count',
    method: 'get',
    params: parameter
  })
}

/* 退款订单数据统计 */
export function $refundOrderCount (parameter) {
  return request.request({
    url: '/api/refundOrder/count',
    method: 'get',
    params: parameter
  })
}

/* 渠道账单数据统计 */
export function $channelBillCount (parameter) {
  return request.request({
    url: '/api/channel/bill/count',
    method: 'get',
    params: parameter
  })
}

/** 分账重试 */
export function $resendDivision (recordIds, isResendAndRecalAmount) {
  return request.request({
    url: '/api/division/records/resend',
    method: 'POST',
    data: { recordIds, isResendAndRecalAmount}
  })
}

/** 分账完结 */
export function $finsihDivision (recordIds) {
  return request.request({
    url: '/api/division/records/finish',
    method: 'POST',
    data: { recordIds}
  })
}


/** 预先检查*/
export function $applyPreCheck (mchNo, ifCode) {
  return request.request({
    url: '/api/mchApplyments/applyPreCheck/' + mchNo + '/' + ifCode,
    method: 'GET'
  })
}

/** 服务商渠道参数配置*/
export function $getIsvChannelConfig (mchNo, ifCode) {
  return request.request({
    url: '/api/mchApplyments/getIsvChannelConfig/' + mchNo + '/' + ifCode,
    method: 'GET'
  })
}

/** 查询网站配置信息 */
export function $getSiteInfos () {
  return request.request({
    url: '/api/anon/siteInfos',
    method: 'GET',
    params: { queryConfig: 1 }
  })
}
/** 查询地图配置 */
export function $getMapConfig () {
  return request.request({
    url: '/api/mchStore/mapConfig',
    method: 'get'
  })
}

/** 测试云喇叭播报接口*/
export function $speakTest(deviceId, amount) {
  return request.request({
    url: '/api/store/device/speak/' + deviceId,
    method: 'POST',
    data: { amount }
  })
}

/** 测试云打印接口*/
export function $printTest(deviceId, amount) {
  return request.request({
    url: '/api/store/device/print/' + deviceId,
    method: 'POST',
    data: { amount }
  })
}

/** 清空打印队列接口 */
export function $clearPrint(deviceId) {
  return request.request({
    url: '/api/store/device/clear/' + deviceId,
    method: 'POST'
  })
}

/** 绑定设备 */
export function $bindDevice(recordId, bindObject) {
  return request.request({
    url: '/api/store/device/bind/' + recordId,
    data: bindObject,
    method: 'PUT'
  })
}

/** 商户初始化 */
export function $initialMch(recordId, bindObject) {
  return request.request({
    url: '/api/store/device/initialMchAndYhcDeviceBinding/' + recordId ,
    data: bindObject,
    method: 'PUT'
  })
}

/** 绑定设备 */
export function $yhcDeviceBinding(recordId,produceUid, bindObject) {
  return request.request({
    url: '/api/store/device/yhcDeviceBinding/' + recordId + produceUid,
    data: bindObject,
    method: 'PUT'
  })
}


/** 解绑设备 */
export function $unbindDevice(recordId) {
  return request.request({
    url: '/api/store/device/unbind/' + recordId,
    method: 'POST'
  })
}

/** 划拨设备 */
export function $allotDevice(allotObject) {
  return request.request({
    url: '/api/store/device/allotDevice',
    data: allotObject,
    method: 'POST'
  })
}

/** 批量删除设备 */
export function $batchDelDevice(deviceIds) {
  return request.request({
    url: '/api/store/device',
    data: { delDeviceIds : deviceIds },
    method: 'DELETE'
  })
}

/** 绑定码牌 */
export function $bindQrc(recordId, bindObject) {
  return request.request({
    url: '/api/mchQrCodes/bind/' + recordId,
    data: bindObject,
    method: 'PUT'
  })
}

/** 解绑码牌 */
export function $unbindQrc(recordId) {
  return request.request({
    url: '/api/mchQrCodes/unbind/' + recordId,
    method: 'POST'
  })
}

/** 码牌受支持设备列表 */
export function $bindDeviceList(recordId, params) {
  return request.request({
    url: '/api/mchQrCodes/bindDevice/' + recordId,
    data: params,
    method: 'GET'
  })
}

/** 划拨码牌 */
export function $allotQrc(allotObject) {
  return request.request({
    url: '/api/mchQrCodes/allotQrc',
    data: allotObject,
    method: 'POST'
  })
}

/** 区间划拨码牌校验 */
export function $check4RangeAllot(allotObject) {
  return request.request({
    url: '/api/mchQrCodes/check4RangeAllot',
    data: allotObject,
    method: 'POST'
  })
}

/** 批量删除码牌 */
export function $batchDelQrc(delQrcIds) {
  return request.request({
    url: '/api/mchQrCodes',
    data: { delQrcIds : delQrcIds },
    method: 'DELETE'
  })
}


/** 审核提现 */
export function $cashoutAudit(rid, reqData) {
  return request.request({
    url: '/api/cashouts/audit/' + rid,
    data: reqData,
    method: 'POST'
  })
}

/** 提现人工结算 */
export function $cashoutProcess(rid, reqData) {
  return request.request({
    url: '/api/cashouts/recordProcess/' + rid,
    data: reqData,
    method: 'POST'
  })
}

/** 查询平台账户 */
export function $getPlatformProfit() {
  return request.request({
    url: '/api/account/platformProfit',
    method: 'GET'
  })
}
/** 拓展员商户统计数据*/
export function $userChart(sysUserId, queryDateRange) {
  return request.request({
    url: '/api/mainChart/userChart',
    method: 'GET',
    params: { sysUserId, queryDateRange },
  })
}

// -- 支付接口参数 & 费率配置组件 接口 --

/** 费率配置：获取全部接口 */
export function $getPayConfigIfcodes(infoId, configMode, ifName) {
  return request.request({
    url: '/api/payConfig/ifCodes',
    params: { infoId, configMode, ifName },
    method: 'GET'
  })
}

/**查询商户应用支付参数、费率是否配置 */
export function $getMchPayParamsExist (infoId, ifCode) {
  return request.request({
    url: '/api/payConfig/existPayParams/' + infoId + '/' + ifCode,
    method: 'get'
  })
}

/**查询某一进件记录下，商户应用支付通道是否已配置 */
export function $getMchPayPassageExist (applyId, appId) {
  return request.request({
    url: '/api/mch/payPassages/exist/' + applyId + '/' + appId,
    method: 'get'
  })
}

/** 进件成功，一键配置应用支付信息 */
export function $autoConfigMchPayInfo (applyId, appId, data) {
  return request.request({
    url: '/api/mch/payPassages/applyment/' + applyId + '/' + appId,
    method: 'post',
    data: data
  })
}

/**查询已经配置的参数 */
export function $getInterfaceSavedConfigs (infoId, ifCode, configMode, qcreals = 0) {
  return request.request({
    url: '/api/payConfig/interfaceSavedConfigs',
    method: 'get',
    params: { infoId, ifCode, configMode, qcreals}
  })
}

/**更新支付参数配置的参数 */
export function $saveInterfaceParams (data) {
  return request.request({
    url: '/api/payConfig/interfaceParams',
    method: 'post',
    data: data
  })
}

/** 费率配置：获取 支付方式 */
export function $getRateConfigPayways(infoId, configMode, ifCode) {
  return request.request({
    url: '/api/rateConfig/payways',
    params: { infoId, configMode, ifCode },
    method: 'GET'
  })
}

/** 费率配置：获取 支付方式 */
export function $getRateConfigSavedMapData(infoId, configMode, ifCode) {
  return request.request({
    url: '/api/rateConfig/savedMapData',
    params: { infoId, configMode, ifCode },
    method: 'GET'
  })
}

/** 费率配置：保存 */
export function $saveRateConfig(reqData) {
  return request.request({
    url: '/api/rateConfig',
    data: reqData,
    method: 'POST'
  })
}


/** 商户支付通道配置 （ 左侧列表  ） **/
// export const API_URL_MCH_PAYPASSAGE_LIST = '/api/mch/payPassages'


/** 商户通道选中： 右侧列表 */
export function $getAvailablePayInterfaceList (mchNo, wayCode) {
  return request.request({
    url: '/api/mch/payPassages/availablePayInterface/' + mchNo + '/' + wayCode,
    method: 'GET'
  })
}


/** 更新商户的通道状态*/
export function $updateMchPassageState(appId, wayCode, ifCode, state) {
  return request.request({
    url: '/api/mch/payPassages/mchPassage',
    method: 'POST',
    params: { appId, wayCode, ifCode, state},
  })
}

// -- 支付接口参数 & 费率配置组件 接口 --


/** 查询新建二维码的批次号个数*/
export function $selectBatchIdDistinctCount () {
  return request.request({
    url: '/api/mchQrCodes/batchIdDistinctCount',
    method: 'GET'
  })
}

/** 进件 动态获取银行支行列表*/
export function $bankBranchList (mchNo, ifCode, params) {
  return request.request({
    url: '/api/mchApplyments/bankList/' + mchNo + '/' + ifCode,
    params: params,
    method: 'GET'
  })
}

/** 进件 动态获取地区信息列表*/
/* export function $getAreaCodeList (mchNo, ifCode, params) {
  return request.request({
    url: '/api/mchApplyments/areaCode/' + mchNo + '/' + ifCode,
    params: params,
    method: 'GET'
  })
} */


/** 代理商调账*/
export function $agentChangeBalance (reqParams, agentId) {
  return request.request({
    url: '/api/agents/balanceAmounts/' + agentId,
    data: reqParams,
    method: 'POST'
  })
}

/** 更新默认设备 */
export function $updateMchTermDefault (trmId, defaultFlag) {
  return request.request({
    url: '/api/mchTerminals/trmDefaults',
    data: {trmId, defaultFlag},
    method: 'PUT'
  })
}

/** 报备信息集合 */
export function $getMchTermChannelBindInfos (trmId) {
  return request.request({
    url: '/api/mchTerminals/channelBindInfos/' + trmId,
    method: 'GET'
  })
}

/** 接口报备 */
export function $mchTermChannelSendup (trmId, ifCode, state) {
  return request.request({
    url: '/api/mchTerminals/channelSendup/' + trmId,
    data: { ifCode, state },
    method: 'POST'
  })
}


/** 更新信息 */
export function $updMchTermChannelBindInfos (trmId, data) {
  return request.request({
    url: '/api/mchTerminals/channelBindInfos/' + trmId,
    data: data,
    method: 'POST'
  })
}

/* 富友电子协议生成 */
export function $elecContractGenerate (applyId) {
  return request.request({
    url: '/api/mchApplyments/elecContractGenerate/' + applyId,
    method: 'post'
  })
}

/* 富友电子协议签署 */
export function $elecContractSign (applyId) {
  return request.request({
    url: '/api/mchApplyments/elecContractSign/' + applyId,
    method: 'post'
  })
}

/* 富友  上传图片 */
export function $fuiouUpload (applyId) {
  return request.request({
    url: '/api/mchApplyments/fuiouUpload/' + applyId,
    method: 'post'
  })
}

/* 富友  提交审核 */
export function $fuiouConfirm (applyId) {
  return request.request({
    url: '/api/mchApplyments/fuiouConfirm/' + applyId,
    method: 'post'
  })
}

/* 富友微信参数配置 */
export function $fuiouWxSet (applyId, data) {
  return request.request({
    url: '/api/mchApplyments/fuiouWxConfigSet/' + applyId,
    method: 'post',
    data: data,
  })
}

/* 富友微信参数查询 */
export function $fuiouWxGet (applyId) {
  return request.request({
    url: '/api/mchApplyments/fuiouWxConfigGet/' + applyId,
    method: 'post'
  })
}


/* 分账： 账户余额查询 */
export function $divisionReceiverBalance (recordId) {
  return request.request({
    url: '/api/divisionReceivers/channelBalances/' + recordId,
    method: 'get'
  })
}

/* 分账： 账户余额提现 */
export function $divisionReceiverCashout (recordId, cashoutAmount) {
  return request.request({
    url: '/api/divisionReceivers/channelCashout/' + recordId,
    data: { cashoutAmount },
    method: 'POST'
  })
}


/* 应用： 查询系统公钥 */
export function $getSysRSA2PublicKey () {
  return request.request({
    url: '/api/mchApps/sysRSA2PublicKey',
    method: 'GET'
  })
}

/** 解除登录限制 **/
export function $deleteLoginLimit (recordId) {
  return request.request({
    url: '/api/sysUsers/loginLimit/' + recordId,
    method: 'delete'
  })
}

/* 斗拱分账配置 */
export function $dgpayConfigOpen (applyId, reqParams) {
  return request.request({
    url: '/api/mchApplyments/dgpayConfigOpen/' + applyId,
    data: reqParams,
    method: 'post'
  })
}

/* 斗拱分账配置查询 */
export function $dgpayConfigOpenQuery (applyId) {
  return request.request({
    url: '/api/mchApplyments/dgpayConfigOpenQuery/' + applyId,
    method: 'get'
  })
}

/* 乐刷业务开通 */
export function $leshuapayConfigOpen (applyId, reqParams) {
  return request.request({
    url: '/api/mchApplyments/leshuapayConfigOpen/' + applyId,
    data: reqParams,
    method: 'post'
  })
}

/* 斗拱微信参数配置 */
export function $dgWxSet (applyId, data) {
  return request.request({
    url: '/api/mchApplyments/dgWxConfigSet/' + applyId,
    method: 'post',
    data: data
  })
}

/* 斗拱微信实名认证 */
export function $dgpayWxRealName (applyId, reqParams) {
  return request.request({
    url: '/api/mchApplyments/dgpayWxRealName/' + applyId,
    data: reqParams,
    method: 'post'
  })
}

/* 银联前置  新增支付类型 */
export function $payConfAdd (applyId, reqParams) {
  return request.request({
    url: '/api/mchApplyments/payConf/' + applyId,
    data: reqParams,
    method: 'post'
  })
}

/* 银联前置  查询第三方交易识别码 */
export function $getMchPartner (applyId, mchAppId, appConfigModeAndIfCode) {
  return request.request({
    url: '/api/mchApplyments/mchPartner/' + applyId + '/' + mchAppId,
    method: 'post',
    data: { appConfigModeAndIfCode }
  })
}

/* 获取请求参数 */
export function $lklApplymentAppConfig (applyId, mchAppId, reqParams) {
  return request.request({
    url: '/api/mchApplyments/lklAppConfig/' + applyId + '/' + mchAppId,
    data: reqParams,
    method: 'post'
  })
}

/* 获取终端记过参数 */
export function $sqbActivationConfig (reqParams) {
  return request.request({
    url: '/api/mchConfig/activation',
    data: reqParams,
    method: 'post',
  })
}

/* 预审核 */
export function $applymentPreAudit (recordId, reqParams) {
  return request.request({
    url: '/api/mchApplyments/preAudit/' + recordId,
    data: reqParams,
    method: 'post',
  })
}

/* 银盛  上传图片 */
export function $yspayUpload (applyId, reqParams) {
  return request.request({
    url: '/api/mchApplyments/yspayUpload/' + applyId,
    data: reqParams,
    method: 'post'
  })
}

/* 银盛  资料确认 */
export function $yspayConfirm (applyId, reqParams) {
  return request.request({
    url: '/api/mchApplyments/yspayConfirm/' + applyId,
    data: reqParams,
    method: 'post'
  })
}

/* 银盛  签约通知重发 */
export function $ysSignSendAgain (applyId) {
  return request.request({
    url: '/api/mchApplyments/ysSignSendAgain/' + applyId,
    method: 'post'
  })
}

/* 银盛  发起合同签约 */
export function $ysSignApply (applyId, params) {
  return request.request({
    url: '/api/mchApplyments/ysSignApply/' + applyId,
    method: 'post',
    data: params
  })
}

/* 银盛  签约结果查询 */
export function $ysSignQuery (applyId) {
  return request.request({
    url: '/api/mchApplyments/ysSignQuery/' + applyId,
    method: 'post'
  })
}

/* 银盛  新增支付类型 */
export function $ysPayRateConfig (applyId, reqParams) {
  return request.request({
    url: '/api/mchApplyments/ysPayRateConfig/' + applyId,
    data: reqParams,
    method: 'post'
  })
}

/* 银盛微信配置 */
export function $yspayConfigInterfaceConfig (applyId, mchAppId, configType, configVal) {
  return request.request({
    url: '/api/mchApplyments/yspayInterfaceConfig/' + applyId + '/' + mchAppId,
    method: 'post',
    data: { configType, configVal }
  })
}

/* 服务商参数查询页面展示 */
export function $getParamsIsvToBack (mchNo, ifCode) {
  return request.request({
    url: '/api/mchApplyments/getParamsIsvToBack/' + mchNo + '/' + ifCode,
    method: 'GET'
  })
}



/* 瑞银信获取银行开户支行信息列表 */
export function $ruipayGetBankList (ifCode, headBankNo, mchNo, queryData) {
  return request.request({
    url: '/api/mchApplyments/bankCode/' + ifCode,
    method: 'get',
    params: { headBankNo, mchNo, queryData },
  })
}

/* 星驿付获取银行开户支行信息列表 */
export function $terpayGetBankList (ifCode, queryBankData) {
  return request.request({
    url: '/api/mchApplyments/bankCode/' + ifCode,
    method: 'get',
    params: queryBankData,
  })
}


/* 星驿付发送短信验证码 */
export function $terpayAnSignMsg (ifCode, mchNo, applyId, terpayApplymentjsonStrInfo) {
  return request.request({
    url: '/api/mchApplyments/iApplyRes/sendPubRequst/' + ifCode,
    method: 'post',
    data: { mchNo, applyId, jsonStr: JSON.stringify(terpayApplymentjsonStrInfo) }
  })
}

/**查询已经配置的oauth2参数 */
export function $getOauth2SavedConfigs (infoId, ifCode, configMode) {
  return request.request({
    url: '/api/payOauth2Config/savedConfigs',
    method: 'get',
    params: { infoId, ifCode, configMode }
  })
}

/**更新oauth2配置的参数 */
export function $saveOauth2ConfigParams (data) {
  return request.request({
    url: '/api/payOauth2Config/configParams',
    method: 'post',
    data: data
  })
}

/** 查询出diy列表  */
export function $getOauth2DiyList (infoId, configMode) {
  return request.request({
    url: '/api/payOauth2Config/diyList',
    method: 'get',
    params: { infoId, configMode }
  })
}

/** 新增 diy列表  */
export function $addOauth2DiyList (infoId, configMode, remark, copySourceInfoId) {
  return request.request({
    url: '/api/payOauth2Config/diyList',
    method: 'POST',
    data: { infoId, configMode, remark, copySourceInfoId }
  })
}

/** 批量删除广告 */
export function $batchDelAdvert(advertIds) {
  return request.request({
    url: '/api/advert',
    data: { delAdvertIds : advertIds },
    method: 'DELETE'
  })
}

/** 创建支付收银台地址 **/
export function $mchConfigCreateCashier(parameter) {
  return request.request({
    url: '/api/mchConfig/createCashier',
    method: 'POST',
    data: parameter
  })
}

/** 支付宝安全发授权 **/
export function $alipayAgreementPageSign (mchAppId) {
  return request.request({
    url: '/api/mch/payConfigs/alipayAgreementPageSign/' + mchAppId,
    method: 'GET'
  })
}

/** 查询支付宝安全发授权结果 **/
export function $queryUserAgreementPageSign (mchAppId) {
  return request.request({
    url: '/api/mch/payConfigs/queryUserAgreementPageSign/' + mchAppId,
    method: 'GET'
  })
}

/** 会员手动调账 **/
export function $memberChangeBalancePage (recordId, realReqObject) {
  return request.request({
    url: '/api/member/manual/' + recordId,
    method: 'post',
    data: realReqObject
  })
}

/* 会员充值记录数据统计 */
export function $rechargeRecordCount (parameter) {
  return request.request({
    url: '/api/member/rechargeRecord/count',
    method: 'get',
    params: parameter
  })
}

/* 会员账户流水数据统计 */
export function $memberAccountHistoryCount (parameter) {
  return request.request({
    url: '/api/member/accountHistory/count',
    method: 'get',
    params: parameter
  })
}

/* 转账订单数据统计 */
export function $transferOrdersCount (parameter) {
  return request.request({
    url: '/api/transferOrders/count',
    method: 'get',
    params: parameter
  })
}

/* 会员数据统计 */
export function $memberInfoCount (parameter) {
  return request.request({
    url: '/api/member/count',
    method: 'get',
    params: parameter
  })
}

/* 进件api */
export function $applymentNextBiz (applyId, parameter) {
  return request.request({
    url: '/api/mchApplyments/applymentNextBiz/' + applyId,
    method: 'post',
    data: parameter
  })
}

/* 提现数据统计 */
export function $cashoutCount (parameter) {
  return request.request({
    url: '/api/cashouts/count',
    method: 'get',
    params: parameter
  })
}

/* 代理商列表统计 */
export function $agentInfoCount (parameter) {
  return request.request({
    url: '/api/agents/count',
    method: 'get',
    params: parameter
  })
}

/* 厂商设备参数获取 */
export function $getProviderParams (reqUrl, parameter) {
  return request.request({
    url: API_URL_PROVIDER_DEVICE + reqUrl,
    method: 'get',
    params: parameter
  })
}

/* 河马付后续流程 */
export function $hmpayAfterOperate (ifCode, mchNo, applyId, operationType, hmApplyData) {
  return request.request({
    url: '/api/mchApplyments/iApplyRes/sendPubRequst/' + ifCode,
    method: 'post',
    data: { mchNo: mchNo, applyId: applyId, operationType: operationType, jsonStr: JSON.stringify(hmApplyData) }
  })
}

/* 河马查询商户门店信息 */
export function $hmpayQueryStoreInfo (applyId) {
  return request.request({
    url: '/api/mchApplyments/storeApplyment/' + applyId,
    method: 'get'
  })
}

// 短信信息 余额查询接口
export function $getSmsBalance(bizQueryType){
  return request.request({
    url: API_URL_SYS_CONFIG + '/smsBalance',
    method: 'get',
    data: { bizQueryType: bizQueryType }
  })
}

// 商户二维码： 查询支付系统的url
export function $getqrCodePaySiteUrl(){
  return request.request({
    url: API_URL_MCH_QR_CODE_LIST + '/paySiteUrl',
    method: 'get',
    data: { }
  })
}

// 查询克隆信息
export function $queryCloneInfos(ifCode){
  return request.request({
    url: API_URL_IFDEFINES_LIST + '/cloneInfos/' + ifCode,
    method: 'get',
    data: { }
  })
}

// 更新副本配置信息
export function $syncConfigInfo2CloneIfCodes(ifCode){
  return request.request({
    url: API_URL_IFDEFINES_LIST + '/syncConfigInfo2CloneIfCodes/' + ifCode,
    method: 'put',
    data: { }
  })
}
/* 拉卡拉saas支行列表 */
export function $lklGetBankList (areaCode, bankName) {
  return request.request({
    url: '/api/mchApplyments/getLklBankList/' + areaCode,
    method: 'get',
    params: { bankName }
  })
}

/** 提现选择 灵活用工渠道时， 查询当前配置的自营商户的应用信息 */
export function $queryPlatformSelfMchNoAppInfos(rid) {
  return request.request({
    url: '/api/cashouts/platformSelfMchNoAppInfos',
    params: { rid },
    method: 'GET'
  })
}

/** 直付通批量结算 */
export function $zftBattchSett(data) {
  return request.request({
    url: API_URL_ZFT_SETT_RECORD + '/batchSett',
    data: data,
    method: 'POST'
  })
}

/** 支付宝直付通商户作废接口 */
export function $zftMchDelete(appId, smId) {
  return request.request({
    url: API_URL_MCH_APPLYMENT_LIST + '/zftMchDelete/' + appId + '/' + smId,
    method: 'POST'
  })
}

/** 代理商配置 */
export function $getAgentConfig(configKey) {
  return request.request({
    url: API_URL_AGENT_CONFIG + '/' + configKey,
    method: 'GET'
  })
}
/* 活动管理 （渠道侧活动报名）lklspay */
export function $joinActivity (ifCode, data) {
  return request.request({
    url: API_URL_CHANNEL_ACTIVITY + '/' + ifCode,
    method: 'POST',
    data: data
  })
}
